package com.onlinelearn.apigateway.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GatewayConfig {
    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
            // 用户服务路由
            .route("user_service", r -> r.path("/api/users/**")
                .uri("lb://user-service"))
            
            // 认证服务路由  
            .route("auth_service", r -> r.path("/api/auth/**")
                .uri("lb://auth-service"))
            
            // 课程服务路由
            .route("course_service", r -> r.path("/api/courses/**")
                .uri("lb://course-service"))
            
            // 支付服务路由
            .route("payment_service", r -> r.path("/api/payments/**")
                .uri("lb://payment-service"))
            
            // 通知服务路由
            .route("notify_service", r -> r.path("/api/notifications/**")
                .uri("lb://notify-service"))
            
            // 聊天服务路由
            .route("chat_service", r -> r.path("/api/chat/**")
                .uri("lb://chat-service"))
            .build();
    }
} 